package generator.website;

import java.util.Iterator;
import org.eclipse.emf.common.util.EList;
import CarProject.*;;

public class WebxmlCreation
{
  protected static String nl;
  public static synchronized WebxmlCreation create(String lineSeparator)
  {
    nl = lineSeparator;
    WebxmlCreation result = new WebxmlCreation();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + NL + "<web-app xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + NL + "\txmlns=\"http://java.sun.com/xml/ns/javaee\"" + NL + "\txsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\"" + NL + "\tid=\"WebApp_ID\" version=\"2.5\">" + NL + "\t<display-name>TutorialStruts</display-name>" + NL + "\t<welcome-file-list>" + NL + "\t\t<welcome-file>pages/";
  protected final String TEXT_2 = ".jsp</welcome-file>" + NL + "\t</welcome-file-list>" + NL + "\t<!-- declaring a JDBC data source -->" + NL + "\t<resource-ref>" + NL + "\t\t<description>JDBC resource to access my DB i.e." + NL + "dfj_hibernate</description>" + NL + "\t\t<res-ref-name>jdbc/dsMyDB</res-ref-name>" + NL + "\t\t<res-type>javax.sql.DataSource</res-type>" + NL + "\t\t<res-auth>Container</res-auth>" + NL + "\t</resource-ref>" + NL + "" + NL + "" + NL + "" + NL + "\t<!-- Configuration de l'action servlet -->" + NL + "\t<servlet>" + NL + "\t\t<servlet-name>action</servlet-name>" + NL + "\t\t<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>" + NL + "\t\t<init-param>" + NL + "\t\t\t<param-name>config</param-name>" + NL + "\t\t\t<param-value>/WEB-INF/struts-config.xml</param-value>" + NL + "\t\t</init-param>" + NL + "\t\t<load-on-startup>1</load-on-startup>" + NL + "\t</servlet>" + NL + "\t<!-- Action Servlet Mapping -->" + NL + "\t<servlet-mapping>" + NL + "\t\t<servlet-name>action</servlet-name>" + NL + "\t\t<!-- indique que toutes les url .do atterrirons chez l?Action Servlet de " + NL + "\t\t\tStruts -->" + NL + "\t\t<url-pattern>*.do</url-pattern>" + NL + "\t</servlet-mapping>" + NL + "" + NL + "" + NL + "" + NL + "</web-app>";

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
     SiteWeb site = (SiteWeb) argument; 
    stringBuffer.append(TEXT_1);
    stringBuffer.append(((VueGenerale)site.getVue().get(0)).getNomVue());
    stringBuffer.append(TEXT_2);
    return stringBuffer.toString();
  }
}
